package com.xbongbong.saas.service;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.pojo.SyncConditionPojo;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.pro.publicgroup.pojo.dto.PublicGroupGetConditionDTO;
import com.xbongbong.pro.publicgroup.pojo.dto.PublicGroupSetDeleteDTO;
import com.xbongbong.pro.publicgroup.pojo.dto.PublicGroupSetItemDTO;
import com.xbongbong.pro.publicgroup.pojo.dto.PublicGroupSetListDTO;
import com.xbongbong.pro.publicgroup.pojo.dto.PublicGroupSetSaveDTO;
import com.xbongbong.pro.publicgroup.pojo.vo.PublicGroupGetConditionVO;
import com.xbongbong.pro.publicgroup.pojo.vo.PublicGroupItemListVO;
import com.xbongbong.pro.publicgroup.pojo.vo.PublicGroupSetDeleteVO;
import com.xbongbong.pro.publicgroup.pojo.vo.PublicGroupSetItemVO;
import com.xbongbong.pro.publicgroup.pojo.vo.PublicGroupSetListVO;
import com.xbongbong.pro.publicgroup.pojo.vo.PublicGroupSetSaveVO;
import com.xbongbong.saas.domain.entity.PublicGroupEntity;
import com.xbongbong.saas.domain.entity.PublicGroupSeniorEntity;
import com.xbongbong.saas.domain.entity.ext.CustomerEntity;
import com.xbongbong.sys.domain.entity.UserEntity;

import java.util.List;
import java.util.Map;

/**
 * @description: 公海池分组
 * @Author: hongxiao
 * @date: 2019-03-03 14:58
 * @since v1.0
 */
public interface PublicGroupService {
    /**
     * 分组列表
     *
     * @param setListDTO 入参
     * @return
     * @throws
     * @author hongxiao
     * @date: 2019-03-03 17:23
     * @version
     * @since
     */
    PublicGroupSetListVO setList(PublicGroupSetListDTO setListDTO) throws XbbException;

    /**
     * 编辑分组信息
     *
     * @param setItemDTO 入参
     * @return
     * @throws
     * @author hongxiao
     * @date: 2019-03-03 17:23
     * @version
     * @since
     */
    PublicGroupSetItemVO setItem(PublicGroupSetItemDTO setItemDTO) throws XbbException;

    PublicGroupItemListVO groupItemList(PublicGroupSetListDTO setListDTO) throws XbbException;

    /**
     * 保存分组
     *
     * @param setSaveDTO 入参
     * @return
     * @throws
     * @author hongxiao
     * @date: 2019-03-03 17:23
     * @version
     * @since
     */
    PublicGroupSetSaveVO setSave(PublicGroupSetSaveDTO setSaveDTO) throws XbbException;

    /**
     * 删除分组
     *
     * @param setDeleteDTO 入参
     * @return
     * @throws
     * @author hongxiao
     * @date: 2019-03-03 17:23
     * @version v1.0
     * @since v1.0
     */
    PublicGroupSetDeleteVO setDelete(PublicGroupSetDeleteDTO setDeleteDTO) throws XbbException;

    /**
     * 获取筛选条件
     *
     * @param getConditionDTO 入参
     * @return
     * @throws
     * @author hongxiao
     * @date: 2019-03-03 17:23
     * @version v1.0
     * @since v1.0
     */
    PublicGroupGetConditionVO getCondition(PublicGroupGetConditionDTO getConditionDTO) throws XbbException;
    /**
     * 根据字段attr获取筛选条件
     */
    SyncConditionPojo getConditionByAttr(String attr, Long formId, String corpid) throws XbbException;
    /*
     * ====================== 表单组调用方法 start ===================
     */


    /**
     * 获取用户可见的公海池分组
     *
     * @param user   用户实体
     * @param formId 客户表单id
     * @return
     * @throws
     * @author hongxiao
     * @date: 2019-03-19 20:42
     * @version v1.0
     * @since v1.0
     */
    List<PublicGroupEntity> getListByUser(UserEntity user, Long formId);

    /**
     * 获取用户可见的公海池
     * @param user
     * @param formIdList
     * @return
     */
    List<PublicGroupEntity> getListByUser(UserEntity user, List<Long> formIdList);

    /**
     * 根据个人权限过滤分组
     * @param list
     * @param user
     * @return
     */
    List<PublicGroupEntity> filterGroupByUser(List<PublicGroupEntity> list, UserEntity user);

    List<PublicGroupSeniorEntity> filterGroupSeniorByUser(List<PublicGroupSeniorEntity> list, UserEntity user);

    PublicGroupItemListVO groupTabList(PublicGroupSetListDTO setListDTO) throws XbbException;

    List<PublicGroupEntity> getListFormIdList(List<Long> formIdList, String corpid);

    /**
     * 获取用户是否有权限查看此公海客户
     * （即该用户是否有此客户所在公海分组的权限）
     *
     * @param userEntity 员工实体
     * @param formId     客户表单Id
     * @return
     * @throws
     * @author hongxiao
     * @date: 2019-03-08 09:43
     * @version v1.0
     * @since v1.0
     */
    boolean hasAuthToThisForm(UserEntity userEntity, Long formId);
    /*
     * ====================== 表单组调用方法 end ===================
     */

}
